package com.example.administrator.myapplication.fragmentlei;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;

import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.Xinzuojiemian;
import com.example.administrator.myapplication.uilts.XingzuoAdapter;

/**
 * Created by 董豪华 on 2017/1/6.
 */
public class Fragment3 extends Fragment {
    XingzuoAdapter adapter ;
    GridView gv_xingzuo;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.zhu_frament3,container,false);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        adapter = new XingzuoAdapter(getActivity());
        gv_xingzuo = (GridView) getActivity().findViewById(R.id.gv_xingzuo);
        gv_xingzuo.setAdapter(adapter);
        final String[] shuzhu = adapter.getShuzhu();
        gv_xingzuo.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(getActivity(), Xinzuojiemian.class);
                intent.putExtra("name",shuzhu[position]);
                startActivity(intent);
            }
        });
    }
}
